package com.yc.cloud.admin.controller;

import com.yc.cloud.common.basic.api.ResponseResult;
import com.yc.cloud.common.orm.CommonPage;
import com.yc.cloud.admin.dto.request.AlgModelCreateReqDTO;
import com.yc.cloud.admin.dto.request.AlgModelQueryReqDTO;
import com.yc.cloud.admin.dto.request.AlgModelUpdateReqDTO;
import com.yc.cloud.admin.vo.AlgModelVo;
import com.yc.cloud.admin.service.AlgModelService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import jakarta.annotation.Resource;

/**
 * <p>
 * 算法模型表 前端控制器
 * </p>
 *
 * @author kinggu
 * @since 2025-07-11
 */
@RestController
@Api(tags = "算法模型表")
@RequestMapping("/alg-models")
public class AlgModelController {

    @Resource
    private AlgModelService algModelService;

    @ApiOperation("创建算法模型表")
    @PostMapping
    public ResponseResult<Boolean> create(@Validated @RequestBody AlgModelCreateReqDTO createReqDTO) {
        return ResponseResult.success(algModelService.create(createReqDTO));
    }

    @ApiOperation("更新算法模型表")
    @PutMapping("/{id}")
    public ResponseResult<Boolean> update(@PathVariable("id") Long id, @Validated @RequestBody AlgModelUpdateReqDTO updateReqDTO) {
        updateReqDTO.setId(id);
        return ResponseResult.success(algModelService.update(updateReqDTO));
    }

    @ApiOperation("删除算法模型表")
    @DeleteMapping("/{id}")
    public ResponseResult<Boolean> delete(@PathVariable("id") Long id) {
        return ResponseResult.success(algModelService.removeById(id));
    }

    @ApiOperation("获取算法模型表详情")
    @GetMapping("/{id}")
    public ResponseResult<AlgModelVo> getById(@PathVariable("id") Long id) {
        return ResponseResult.success(algModelService.getVOById(id));
    }

    @ApiOperation("分页查询算法模型表")
    @GetMapping
    public ResponseResult<CommonPage<AlgModelVo>> list(@Validated AlgModelQueryReqDTO queryReqDTO) {
        return ResponseResult.success(algModelService.list(queryReqDTO));
    }
}
 